
import os
import sys
import torch
from ..model.speakerverification import AISSpeakerRecognition

def get_feature_lib(dataset_path, save_path, task_id):

    if os.path.exists(save_path):
        if task_id == 2:
            print('  Feature Lib Already Exists!')
        pass
    else:
        if task_id == 2:
            print('  Feature Lib not Exists')
        if torch.cuda.is_available():
            load_device = 'cuda:0'
            if task_id == 2:
                print('  Using GPU: {}.'.format(torch.cuda.get_device_name()))
        else:
            load_device = 'cpu'
            if task_id == 2:
                print('  Using CPU.')
        verification = AISSpeakerRecognition.from_hparams(source="speechbrain/spkrec-ecapa-voxceleb",\
                                            savedir="pretrained_models/spkrec-ecapa-voxceleb",\
                                            run_opts={"device": load_device})

        verification.get_feature_lib(dataset_path, save_path)

